﻿<Page 
    x:Class="Milkify.Views.TaskControl" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Milkify"
    xmlns:mi="clr-namespace:Milkify.Input"
    xmlns:mv="clr-namespace:Milkify.Views"
    Title="Task"
    KeepAlive="True"
    KeyboardNavigation.IsTabStop="False">
    <DockPanel
        KeyboardNavigation.IsTabStop="False"
        KeyboardNavigation.TabNavigation="Local">
        <Grid
            Name="IncompleteTaskFunctions"
            KeyboardNavigation.TabIndex="1"
            DockPanel.Dock="Bottom">
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button
                Grid.Column="0"
                Content="Complete"
                Command="{Binding CompleteTaskCommand}" />
            <Button
                Grid.Column="1"
                Content="Edit"
                Command="{Binding EditTaskCommand}" />
            <Button
                Grid.Column="2"
                Content="Postpone"
                Command="{Binding PostponeTaskCommand}" />
            <Button
                Grid.Column="3"
                Content="Delete"
                Command="{Binding DeleteTaskCommand}" />
        </Grid>
        <Grid
            Name="CompletedTaskFunctions"
            KeyboardNavigation.TabIndex="2"
            DockPanel.Dock="Bottom">
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button
                Grid.Column="0"
                Content="Uncomplete"
                Command="{Binding UncompleteTaskCommand}" />
        </Grid>
        <Grid
            KeyboardNavigation.TabIndex="0"
            Style="{DynamicResource TaskPanelStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Style="{DynamicResource TaskPropertyTextStyle}">Task name: </TextBlock><TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Task.Name}" TextWrapping="Wrap" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.NameParameter}" />
            <TextBlock Grid.Row="1" Style="{DynamicResource TaskPropertyTextStyle}">List: </TextBlock><TextBlock Grid.Row="1" Grid.Column="1">
                <Hyperlink
                    Grid.Row="1" Grid.Column="1"
                    NavigateUri="#"
                    Command="{Binding NavigateToTaskListCommand}"><TextBlock Text="{Binding Task.ParentName}" /></Hyperlink></TextBlock>
            <TextBlock Grid.Row="2" Style="{DynamicResource TaskPropertyTextStyle}">Priority: </TextBlock><TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Task.Priority}" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.PriorityParameter}" />
            <TextBlock Grid.Row="3" Style="{DynamicResource TaskPropertyTextStyle}">Due: </TextBlock><TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Task.Due}" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.DueParameter}" />
            <TextBlock Grid.Row="4" Style="{DynamicResource TaskPropertyTextStyle}">Repeat: </TextBlock><TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding Task.Recurrence}" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.RepeatParameter}" />
            <TextBlock Grid.Row="5" Style="{DynamicResource TaskPropertyTextStyle}">Time estimate: </TextBlock><TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding Task.Estimate}" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.EstimateParameter}" />
            <TextBlock Grid.Row="6" Style="{DynamicResource TaskPropertyTextStyle}">URL: </TextBlock><TextBlock Grid.Row="6" Grid.Column="1" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.UrlParameter}"><Hyperlink Name="LinkUrl"  Command="{Binding NavigateToTaskUrlCommand}" CommandParameter="{Binding Task.Url}"><TextBlock Text="{Binding Task.Url}" /></Hyperlink></TextBlock>
            <TextBlock Grid.Row="7" Style="{DynamicResource TaskPropertyTextStyle}">Tags: </TextBlock><ItemsControl 
                Grid.Row="7" 
                Grid.Column="1" 
                Name="ListTags" 
                ItemsSource="{Binding Task.Tags}" 
                KeyboardNavigation.IsTabStop="False"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock>
                            <Hyperlink
                                NavigateUri="#"
                                Command="{Binding ElementName=ListTags, Path=DataContext.NavigateToTagCommand}"
                                CommandParameter="{Binding}">
                                <TextBlock Text="{Binding}" />
                            </Hyperlink>
                            <TextBlock Text=" " />
                        </TextBlock>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel IsItemsHost="True" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
            <TextBlock Grid.Row="8" Style="{DynamicResource TaskPropertyTextStyle}">Location: </TextBlock><TextBlock Grid.Row="8" Grid.Column="1" mi:ExtendedCommands.DoubleClickCommand="{Binding EditTaskParameterCommand}" mi:ExtendedCommands.DoubleClickCommandParameter="{x:Static mv:TaskControl.LocationParameter}"><Hyperlink
                NavigateUri="#"
                Name="LinkLocation"><TextBlock Text="{Binding Task.LocationName}" /></Hyperlink></TextBlock>
            <Button
                Grid.Row="9"
                Grid.ColumnSpan="2"
                Command="{Binding NavigateToTaskNoteListCommand}">
                <Grid
                    HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Notes" />
                    <TextBlock Text="{Binding Task.Notes.Count}" Grid.Column="1" />
                </Grid>
            </Button>
        </Grid>
    </DockPanel>
</Page>
